package com.booking.springrestful.controller;

import com.booking.springrestful.resp.ResponseResult;
import com.booking.springrestful.service.OssService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("/oss")
@Slf4j
public class OssController {
 
    @Resource
    private OssService ossService;
 
    //上传头像，返回图片的url给
    @PostMapping
    public ResponseResult uploadOssFile(@RequestParam("file") MultipartFile file) throws Exception {
        log.info(file.toString());

        //获取上传文件 MultipartFile
        //返回图片在oss上的路径
        return ResponseResult.success(ossService.uploadFileAvatar(file));
    }


 
}